package com.webdev.servlet;

import java.io.IOException;
import java.sql.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.webdev.domain.Record;
import com.webdev.service.RecordService;
import com.webdev.service.imp.RecordServiceImp;

/**
 * Servlet implementation class SignInServlet
 */
@WebServlet("/SignInServlet")
public class SignInServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       

	/**
	 * 签到
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		Record record = new Record();
		record.setPid(Integer.parseInt(request.getParameter("pid")));
		try {
			record.setRdate(new Date(sdf.parse(request.getParameter("rdate")).getTime()));
			
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		record.setRstate(1);
		record.setRinfo("无");
		RecordService service = new RecordServiceImp();
		service.signIn(record);
	}

}
